package com.geline.cloud.service;

import com.geline.sdk.core.BaseSessionService;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 用户登录集成
 * https://help.jeecg.com/jimureport/config/token.html
 *
 * @author: mx
 * @date: 2024-07-20 18:08
 */
@Component
@Slf4j
public class MyTokenService implements JmReportTokenServiceI{

    @Resource
    private BaseSessionService<Long> sessionService;

    @Override
    public String getUsername(String token) {
        Long userId = sessionService.getUserId();
        return userId.toString();
    }

    @Override
    public String[] getRoles(String token) {
        return new String[0];
    }

    @Override
    public Boolean verifyToken(String token) {
        sessionService.checkLogin();
        return true;
    }
}
